<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>订单列表</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript">
        function showOrder(orderId) {
            location.href = "${pageContext.request.contextPath}/orderAll?o_id=" + orderId;
        }

        function changeStatus(orderId) {
            location.href = "${pageContext.request.contextPath}/changeStatus?o_id=" + orderId;
        }
    </script>
    <style>
        body {
            background-color: #f7f7f7;
            margin: 0;
            padding: 20px;
            font-family: 'Arial', sans-serif;
        }

        .row {
            margin-left: 0;
            margin-right: 0;
        }

        .form-control {
            margin-right: 10px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 10px;
        }

        th, td {
            text-align: left;
            padding: 8px;
            border: 1px solid #ddd;
        }

        th {
            background-color: #f2f2f2;
            color: #333;
        }

        tr:nth-child(even) {
            background-color: #f9f9f9;
        }

        .btn-sm {
            padding: 5px 10px;
            margin-right: 5px;
        }

        .btn-danger {
            background-color: #d9534f;
            border-color: #d43f3a;
        }

        .btn-warning {
            background-color: #f0ad4e;
            border-color: #eea236;
        }

        #statusFilter {
            margin-top: 5px;
            margin-bottom: 5px;
        }

        .submit-btn {
            padding: 8px 15px;
            margin-left: 10px; /* 与下拉框保持一定间隔 */
            border: 1px solid #ccc; /* 简约边框 */
            background-color: #f8f8f8; /* 简约背景色 */
            color: #333; /* 文字颜色 */
            cursor: pointer; /* 鼠标悬停时显示手形图标 */
            border-radius: 4px; /* 轻微圆角 */
            font-size: 14px; /* 字体大小 */
        }

        .submit-btn:hover {
            background-color: #e9e9e9; /* 鼠标悬停时的背景色 */
        }
    </style>
</head>
<body style="background-color:#f5f5f5">
<%@ include file="header.jsp" %>
<div class="container" style="background-color: white;">
    <div class="row" style="margin-left: 40px">
        <h3>我的订单列表&nbsp;&nbsp;
            <small>温馨提示：<em>${user.userName}</em>有<font color="red">${orderList.size()}</font>个订单</small></h3>
    </div>
    <div class="row" style="margin-top: 10px;">
        <div class="col-md-12">
            <form class="form-inline" action="${pageContext.request.contextPath}/orderShow" method="post">
                <div class="form-group">
                    <label for="statusFilter">订单状态：</label>
                    <select id="statusFilter" name="statusFilter" class="form-control">
                        <option value="all">全部</option>
                        <option value="0">未支付</option>
                        <option value="1">已支付，待发货</option>
                        <option value="2">已发货，待收货</option>
                        <option value="3">订单完成</option>
                    </select>
                </div>
                <!-- 添加一个按钮用于提交表单 -->
                <button type="submit" class="btn btn-secondary">筛选</button>
            </form>
        </div>
    </div>

    <div class="row" style="margin-top: 20px;">
        <div class="col-md-12" style="margin-top: 10px">
            <table id="tb_list" class="table table-striped table-hover table-bordered table-condensed">
                <tr>
                    <th>序号</th>
                    <th>订单编号</th>
                    <th>总金额</th>
                    <th>订单状态</th>
                    <th>订单时间</th>
                    <th>收货地址</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${orderList}" var="order" varStatus="i">
                    <tr>
                        <th>${i.count}</th>
                        <th>${order.orderId}</th>
                        <th>${order.totalPrice}</th>
                        <th>
                            <font color="red">
                                <c:if test="${order.orderStatus eq 0 }">
                                    未支付
                                </c:if>
                                <c:if test="${order.orderStatus eq 1 }">
                                    已支付,代发货
                                </c:if>
                                <c:if test="${order.orderStatus eq 2 }">
                                    已发货,待收货
                                </c:if>
                                <c:if test="${order.orderStatus eq 3 }">
                                    订单完成
                                </c:if>
                                <c:if test="${order.orderStatus eq 4 }">
                                    .....
                                </c:if>
                            </font>
                        </th>
                        <th>${order.createdTime}</th>
                        <th>${order.address.addrName}</th>
                        <th>
                            <button type="button" class="btn btn-danger btn-sm" onclick="showOrder('${order.orderId}')">
                                订单详情
                            </button>
                        </th>
                    </tr>
                </c:forEach>
            </table>
        </div>
    </div>

</div>


<!-- 底部 -->
<%@ include file="footer.jsp" %>

</body>
</html>